﻿using LongGi.TingkatKebocoranModule.CommModel;
using OxyPlot;
using OxyPlot.Annotations;
using Prism.Mvvm;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace LongGi.TingkatKebocoranModule
{
    public  class MyViewModelBase : BindableBase
    {
        private double _TopValue;
        public double TopValue
        {
            get { return _TopValue; }
            set
            {

                if (double.TryParse(value.ToString(), out double result))
                {
                    var re = ChartCommon.SetLineAnnotation(value, "上限", this.LeakRatePlotModel, _TopAnn);
                    SetProperty(ref _TopValue, value);

                    LeakRatePlotModel = null;
                    LeakRatePlotModel = re.Item2;
                    _TopAnn = re.Item1;
                }
                else
                {

                    LongGiEventCommon.PubshMessageEventHander("请输入正确的上限数据！！");


                }



            }
        }


        private double _BottomValue;
        public double BottomValue
        {
            get { return _BottomValue; }

            set
            {

                if (double.TryParse(value.ToString(), out double result))
                {

                    var (re, mo) = ChartCommon.SetLineAnnotation(value, "下限", this._LeakRatePlotModel, _BottomAnn);
                    SetProperty(ref _BottomValue, value);
                    LeakRatePlotModel = null;
                    LeakRatePlotModel = mo;
                    _BottomAnn = re;
                }
                else
                {

                    LongGiEventCommon.PubshMessageEventHander("请输入正确的下限数据！！");


                }



            }
        }

        private PlotModel _LeakRatePlotModel;
        /// <summary>
        /// 漏率 chart
        /// </summary>
        public PlotModel LeakRatePlotModel
        {
            get { return _LeakRatePlotModel; }
            set
            {

                SetProperty(ref _LeakRatePlotModel, value);
            }
        }
     

        public LineAnnotation _TopAnn = new LineAnnotation()
        {
            Type = LineAnnotationType.Horizontal,
            Y = 0
        };

        public LineAnnotation _BottomAnn = new LineAnnotation()
        {
            Type = LineAnnotationType.Horizontal,
            Y = 0
        };


    }
}
